package com.architect.mvp.android.mvp;

import com.architect.mvp.android.http.HttpUtils;

/**
 * 作者: Dream on 2017/2/26 23:25
 * QQ:510278658
 * E-mail:510278658@qq.com
 */

public class LoginPresenter {

    //MVP中P需要持有M层和V层引用
    private LoginView view;
    private LoginModel model;

    public LoginPresenter(){
        this.model = new LoginModel();
    }

    //绑定V层
    public void attachView(LoginView view){
        this.view = view;
    }

    public void detachView(){
        this.view = null;
    }

    public void login(String name,String password){
        //关联
        this.model.login(name, password, new HttpUtils.OnHttpResultListener() {
            @Override
            public void onResult(String result) {
                if (view != null){
                    view.onLoginResult(result);
                }
            }
        });
    }

}
